package com.besttone.util;

/**
 * Created by zhengzhenzhen on 2017/7/19.
 */
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author zhaochongyang
 */
public class Encryption{
    private static Log log = LogFactory.getLog(Encryption.class);

    /**
     * 加密请求
     */
    public static String getRequestStr(String dateStr) {
        String sign = MD5Plus.getMD5Str(PropertieUtils.getProperty("request_name")+dateStr+
                PropertieUtils.getProperty("request_key"), 1);
        sign = sign.substring(8,sign.length()-8);
        log.info("加密后的字符串："+sign);
        return sign;
    }

    /**
     * 外部接口访问，验证加密
     */
    public static String validRequest(String name, String dateStr, String key) {
        String sign = MD5Plus.getMD5Str(name + dateStr + key, 1);
        sign = sign.substring(8, sign.length() - 8);
        log.info("加密后的字符串：" + sign);
        return sign;
    }

    public static void main(String[] args) {
        //String sign = MD5Plus.getMD5Str("chongyang"+DateUtilPlus.getTimeStr(new Date(), 6)+"123", 1);
        //sign = sign.substring(8,sign.length()-8);
        //System.out.println("加密后的字符串："+sign);
    }
}

